From: dan.boris@coat.com
Subject: Re: 6502 Overflow Flag Behavior Questions
Date: 1997/05/27
Message-ID: <864733780.5989@dejanews.com>#1/1
References: <338668fe.26235392@news.winternet.com> <19970524073201.DAA25120@ladder02.news.aol.com> <Pine.SOL.3.93.970527101149.451b-100000@infernal>
X-Http-User-Agent: Mozilla/3.01 (Win95; I)
X-Originating-IP-Addr: 164.153.13.4 (dc1-pc04.coat.com)
Organization: Deja News Usenet Posting Service
X-Article-Creation-Date: Tue May 27 11:49:41 1997 GMT
X-Authenticated-Sender: dan.boris@coat.com
Newsgroups: comp.emulators.misc




> The result is undefined on the standard (NMOS) 6502; for the CMOS
> 65C02, the flags are updated correctly, at the cost of an extra cycle.
>

It's true that the Overflow flag is technically undefined on the old
6502s, but the results are predictable so it is possible that a program
running on this processor might try to use the Overflow flag.

Here is something I posted a couple weeks ago that might help:

    I have noticed that a lot of people who have written 6502 emulators
have had problems implementing the Binary Coded Decimal math instructions.
To test the behavior of the ADC instruction in decimal mode I ran some
numbers on a real 6502 and the results are shown below. This test was
run on a real Atari 800XL. The two numbers show where added together
using the ADC instruction in decimal mode and the result and resulting
flags are shown.

(All numbers are in Hex)

Num1   Num2  Carryin   | Result    N V Z C
00     00    0         | 00        0 0 1 0
33     22    0         | 55        0 0 0 0
09     01    0         | 10        0 0 0 0
99     01    0         | 00        1 0 0 1
AA     11    0         | 21        1 0 0 1
FF     01    0         | 66        0 0 1 1
0F     02    0         | 17        0 0 0 0
FF     FF    0         | 54        1 0 0 1
99     02    0         | 01        1 0 0 1

Num1   Num2  Carryin   | Result    N V Z C
00     00    1         | 01        0 0 0 0
33     22    1         | 56        0 0 0 0
09     01    1         | 11        0 0 0 0
99     01    1         | 01        1 0 0 1
AA     11    1         | 22        1 0 0 1
FF     01    1         | 67        0 0 0 1
0F     02    1         | 18        0 0 0 0
FF     FF    1         | 55        1 0 0 1
99     02    1         | 02        1 0 0 1

Note that values over 99 are not valid BCD numbers, but they
still do produce predictable results.

                                   Dan Boris

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

